package com.bwie.sync;

import com.bwie.common.domain.ChargingStation;
import com.bwie.common.domain.Vehicle;
import com.bwie.common.redis.RedisCache;
import com.bwie.mapper.ChargingMapper;
import com.bwie.service.ChargingService;
import com.bwie.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.convert.RedisData;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * @Author：ShenJiaFeng
 * @Package：com.bwie.sync
 * @Project：zg6_yuekao
 * @name：ChargingSync
 * @Date：2024/5/17 13:22
 */
@Component
public class ChargingSync {
    @Autowired
    private ChargingService chargingService;
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private VehicleService vehicleService;
    //redis存车辆
    @Scheduled(cron = "0/5 * * * * ?")
    public void chargingSync(){
        List<Vehicle> list = vehicleService.list();
        for (Vehicle vehicle : list) {
            if (!redisCache.hasKey("vehicle")){
                redisCache.setCacheObject("vehicle",vehicle);
            }
        }
    }

}
